<!DOCTYPE HTML>
<html lang="en" >
    <!-- Start book  -->
    <head>
        <!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>伪类选择器 | </title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="../../../gitbook/plugins/gitbook-plugin-splitter/splitter.css">
        
    
        
        <link rel="stylesheet" href="../../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../../md/CSS/selector/weiduixiang.html" />
    
    
    <link rel="prev" href="../../../md/CSS/selector/shuxing.html" />
    

        <!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
        
    <div class="book"
        data-level="2.2.6"
        data-chapter-title="伪类选择器"
        data-filepath="md/CSS/selector/weilei.md"
        data-basepath="../../.."
        data-revision="Tue Sep 19 2017 14:58:58 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="md/HTML5/readme.html">
            
                
                    <a href="../../../md/HTML5/readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        HTML
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="md/HTML5/20170719HTML.html">
            
                
                    <a href="../../../md/HTML5/20170719HTML.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        什么是HTML
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="md/HTML5/biaoqian.html">
            
                
                    <a href="../../../md/HTML5/biaoqian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="md/HTML5/form.html">
            
                
                    <a href="../../../md/HTML5/form.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        表单
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="md/HTML5/form-type.html">
            
                
                    <a href="../../../md/HTML5/form-type.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        form标签的类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="md/HTML5/20170721HTML.html">
            
                
                    <a href="../../../md/HTML5/20170721HTML.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        其他标签的使用
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="md/CSS/readme.html">
            
                
                    <a href="../../../md/CSS/readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        CSS3
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="md/CSS/20170722CSS.html">
            
                
                    <a href="../../../md/CSS/20170722CSS.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        什么是CSS
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="md/CSS/selector.html">
            
                
                    <a href="../../../md/CSS/selector.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        选择器
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="md/CSS/selector/tongpei.html">
            
                
                    <a href="../../../md/CSS/selector/tongpei.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.1.</b>
                        
                        通配选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.2" data-path="md/CSS/selector/yuansu.html">
            
                
                    <a href="../../../md/CSS/selector/yuansu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.2.</b>
                        
                        元素选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.3" data-path="md/CSS/selector/qunzu.html">
            
                
                    <a href="../../../md/CSS/selector/qunzu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.3.</b>
                        
                        群组选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.4" data-path="md/CSS/selector/guanxi.html">
            
                
                    <a href="../../../md/CSS/selector/guanxi.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.4.</b>
                        
                        关系选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.5" data-path="md/CSS/selector/shuxing.html">
            
                
                    <a href="../../../md/CSS/selector/shuxing.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.5.</b>
                        
                        属性选择器
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="2.2.6" data-path="md/CSS/selector/weilei.html">
            
                
                    <a href="../../../md/CSS/selector/weilei.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.6.</b>
                        
                        伪类选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.7" data-path="md/CSS/selector/weiduixiang.html">
            
                
                    <a href="../../../md/CSS/selector/weiduixiang.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.7.</b>
                        
                        伪对象选择器
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="md/CSS/style/readme.html">
            
                
                    <a href="../../../md/CSS/style/readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        常用样式分类
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="md/CSS/style/font.html">
            
                
                    <a href="../../../md/CSS/style/font.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.1.</b>
                        
                        字体样式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="md/CSS/style/box.html">
            
                
                    <a href="../../../md/CSS/style/box.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.2.</b>
                        
                        盒子模型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="md/CSS/style/border.html">
            
                
                    <a href="../../../md/CSS/style/border.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.3.</b>
                        
                        边框样式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3.4" data-path="md/CSS/style/paragraph.html">
            
                
                    <a href="../../../md/CSS/style/paragraph.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.4.</b>
                        
                        段落样式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3.5" data-path="md/CSS/style/background.html">
            
                
                    <a href="../../../md/CSS/style/background.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.5.</b>
                        
                        背景样式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3.6" data-path="md/CSS/style/float.html">
            
                
                    <a href="../../../md/CSS/style/float.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.6.</b>
                        
                        浮动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3.7" data-path="md/CSS/style/position.html">
            
                
                    <a href="../../../md/CSS/style/position.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.7.</b>
                        
                        定位
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3.8" data-path="md/CSS/style/animation.html">
            
                
                    <a href="../../../md/CSS/style/animation.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.8.</b>
                        
                        动画及过渡效果
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3.9" data-path="md/CSS/style/iconfont.html">
            
                
                    <a href="../../../md/CSS/style/iconfont.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.9.</b>
                        
                        外部icon图标库的使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3.10" data-path="md/CSS/style/sanjiaoxing.html">
            
                
                    <a href="../../../md/CSS/style/sanjiaoxing.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.10.</b>
                        
                        利用border画三角形
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3.11" data-path="md/CSS/style/xiaojiao.html">
            
                
                    <a href="../../../md/CSS/style/xiaojiao.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.11.</b>
                        
                        对话框旁边的小角制作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3.12" data-path="md/CSS/style/flex.html">
            
                
                    <a href="../../../md/CSS/style/flex.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.12.</b>
                        
                        弹性盒子
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="md/CSS/idea/readme.html">
            
                
                    <a href="../../../md/CSS/idea/readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        小技巧
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="md/CSS/idea/caret-color.html">
            
                
                    <a href="../../../md/CSS/idea/caret-color.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.1.</b>
                        
                        光标和placeholder颜色
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4.2" data-path="md/CSS/idea/background.html">
            
                
                    <a href="../../../md/CSS/idea/background.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.2.</b>
                        
                        部分背景透明
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="md/mobile/readme.html">
            
                
                    <a href="../../../md/mobile/readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        移动端相关
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" >
            
            <span><b>3.1.</b> [媒体特性与Responsive设计]</span>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="md/mobile/viewport.html">
            
                
                    <a href="../../../md/mobile/viewport.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        视口
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="md/mobile/responsive.html">
            
                
                    <a href="../../../md/mobile/responsive.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        响应式网页
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="md/javascript/readme.html">
            
                
                    <a href="../../../md/javascript/readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        JavaScript
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="md/javascript/strict.html">
            
                
                    <a href="../../../md/javascript/strict.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        JavaScript的严格模式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="md/javascript/value.html">
            
                
                    <a href="../../../md/javascript/value.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        变量
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" >
            
            <span><b>4.3.</b> [对象]</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.3.1" data-path="md/javascript/string.html">
            
                
                    <a href="../../../md/javascript/string.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.1.</b>
                        
                        String
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.2" data-path="md/javascript/array.html">
            
                
                    <a href="../../../md/javascript/array.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.2.</b>
                        
                        Array
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.3" data-path="md/javascript/date.html">
            
                
                    <a href="../../../md/javascript/date.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.3.</b>
                        
                        Date
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.4" data-path="md/javascript/number.html">
            
                
                    <a href="../../../md/javascript/number.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.4.</b>
                        
                        Number
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.5" data-path="md/javascript/math.html">
            
                
                    <a href="../../../md/javascript/math.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.5.</b>
                        
                        Math
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="md/javascript/yunsuanfu.html">
            
                
                    <a href="../../../md/javascript/yunsuanfu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        运算符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="md/javascript/yuju.html">
            
                
                    <a href="../../../md/javascript/yuju.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        语句
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="md/javascript/function.html">
            
                
                    <a href="../../../md/javascript/function.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.6.</b>
                        
                        函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="md/javascript/time.html">
            
                
                    <a href="../../../md/javascript/time.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.7.</b>
                        
                        定时器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="md/javascript/dom.html">
            
                
                    <a href="../../../md/javascript/dom.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.8.</b>
                        
                        DOM操作
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.8.1" data-path="md/javascript/search.html">
            
                
                    <a href="../../../md/javascript/search.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.8.1.</b>
                        
                        查找
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.8.2" data-path="md/javascript/add.html">
            
                
                    <a href="../../../md/javascript/add.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.8.2.</b>
                        
                        增加
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.8.3" data-path="md/javascript/remove.html">
            
                
                    <a href="../../../md/javascript/remove.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.8.3.</b>
                        
                        移除
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="md/javascript/HTML-JavaScript.html">
            
                
                    <a href="../../../md/javascript/HTML-JavaScript.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.</b>
                        
                        在HTML中使用JavaScript
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="md/javascript/CSS-javascript.html">
            
                
                    <a href="../../../md/javascript/CSS-javascript.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.10.</b>
                        
                        JavaScript控制样式和属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="md/javascript/json.html">
            
                
                    <a href="../../../md/javascript/json.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.11.</b>
                        
                        JSON相关
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../../" ></a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x5668;">&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x5668;</h1>
<h2 id="link">link</h2>
<blockquote>
<p>&#x6CA1;&#x88AB;&#x70B9;&#x8FC7;&#x7684;</p>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">a</span>:<span class="hljs-value">link{
    color: black</span></span>;
}
</code></pre>
</blockquote>
<h2 id="visited">visited</h2>
<blockquote>
<p>&#x5DF2;&#x7ECF;&#x88AB;&#x8BBF;&#x95EE;&#x8FC7;&#x4E86;</p>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">a</span>:<span class="hljs-value">visited{
    color: skyblue</span></span>;
}
</code></pre>
</blockquote>
<h2 id="hover">hover</h2>
<blockquote>
<p>&#x9F20;&#x6807;&#x8986;&#x76D6;&#x8EAB;&#x4E0A;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53EF;&#x4EE5;&#x7ED9;&#x522B;&#x7684;&#x6807;&#x7B7E;&#x52A0;</p>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">a</span>:<span class="hljs-value">hover{
    color: red</span></span>;
}
</code></pre>
<pre><code class="lang-css"><span class="hljs-tag">a</span><span class="hljs-rules">{
    <span class="hljs-rule"><span class="hljs-attribute">background</span>:<span class="hljs-value"> gray</span></span>;
    <span class="hljs-rule"><span class="hljs-attribute">transition</span>:<span class="hljs-value">all <span class="hljs-number">2s</span></span></span>;
}</span>
</code></pre>
<p><strong>transition&#x8868;&#x793A;&#x8FC7;&#x6E21;&#x52A8;&#x753B;&#xFF0C;&#x4E00;&#x822C;&#x52A0;&#x7ED9;&#x539F;&#x672C;&#x7684;a&#x6807;&#x7B7E;&#xFF0C;all&#x503C;&#x8868;&#x793A;&#x8FC7;&#x6E21;&#x7684;&#x5C5E;&#x6027;&#xFF08;&#x53EF;&#x5199;color&#xFF09;&#xFF0C;2s&#x503C;&#x8868;&#x793A;&#x8FC7;&#x6E21;&#x65F6;&#x95F4;</strong></p>
</blockquote>
<h2 id="active">active</h2>
<blockquote>
<p>&#x9F20;&#x6807;&#x6FC0;&#x6D3B;&#x8BE5;&#x6807;&#x7B7E;&#x7684;&#x65F6;&#x5019;</p>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">a</span>:<span class="hljs-value">active{
    color: yellow</span></span>;
}
</code></pre>
</blockquote>
<h2 id="focus">focus</h2>
<blockquote>
<p>&#x83B7;&#x53D6;&#x7126;&#x70B9;&#x65F6;&#x7684;&#x72B6;&#x6001;</p>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">.input</span>:<span class="hljs-value">focus{
    color: skyblue</span></span>;
}
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">input</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;text&quot;</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;input&quot;</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">&quot;dd&quot;</span>/&gt;</span>
</code></pre>
</blockquote>
<h2 id="lang">lang</h2>
<blockquote>
<p>&#x5339;&#x914D;&#x4F7F;&#x7528;&#x7279;&#x6B8A;&#x8BED;&#x8A00;&#x7684;&#x67D0;&#x5143;&#x7D20;</p>
</blockquote>
<pre><code class="lang-css"><span class="hljs-pseudo">:lang(fr)</span> &gt; <span class="hljs-tag">q</span> <span class="hljs-rules">{ <span class="hljs-rule"><span class="hljs-attribute">quotes</span>:<span class="hljs-value"> <span class="hljs-string">&apos;&#xAB; &apos;</span> <span class="hljs-string">&apos; &#xBB;&apos;</span></span></span>; }</span>
<span class="hljs-pseudo">:lang(de)</span> &gt; <span class="hljs-tag">q</span> <span class="hljs-rules">{ <span class="hljs-rule"><span class="hljs-attribute">quotes</span>:<span class="hljs-value"> <span class="hljs-string">&apos;&#xBB;&apos;</span> <span class="hljs-string">&apos;&#xAB;&apos;</span> <span class="hljs-string">&apos;\2039&apos;</span> <span class="hljs-string">&apos;\203A&apos;</span></span></span>; }</span>
<span class="hljs-pseudo">:lang(en)</span> &gt; <span class="hljs-tag">q</span> <span class="hljs-rules">{ <span class="hljs-rule"><span class="hljs-attribute">quotes</span>:<span class="hljs-value"> <span class="hljs-string">&apos;\201C&apos;</span> <span class="hljs-string">&apos;\201D&apos;</span> <span class="hljs-string">&apos;\2018&apos;</span> <span class="hljs-string">&apos;\2019&apos;</span></span></span>; }</span>
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">div</span> <span class="hljs-attribute">lang</span>=<span class="hljs-value">&quot;fr&quot;</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-title">q</span>&gt;</span>This French quote has a <span class="hljs-tag">&lt;<span class="hljs-title">q</span>&gt;</span>nested<span class="hljs-tag">&lt;/<span class="hljs-title">q</span>&gt;</span> quote.<span class="hljs-tag">&lt;/<span class="hljs-title">q</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">div</span> <span class="hljs-attribute">lang</span>=<span class="hljs-value">&quot;de&quot;</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-title">q</span>&gt;</span>This German quote has a <span class="hljs-tag">&lt;<span class="hljs-title">q</span>&gt;</span>nested<span class="hljs-tag">&lt;/<span class="hljs-title">q</span>&gt;</span> quote.<span class="hljs-tag">&lt;/<span class="hljs-title">q</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">div</span> <span class="hljs-attribute">lang</span>=<span class="hljs-value">&quot;en&quot;</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-title">q</span>&gt;</span>This English quote has a <span class="hljs-tag">&lt;<span class="hljs-title">q</span>&gt;</span>nested<span class="hljs-tag">&lt;/<span class="hljs-title">q</span>&gt;</span> quote.<span class="hljs-tag">&lt;/<span class="hljs-title">q</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
</code></pre>
<p>&#x7ED3;&#x679C;&#x5982;&#x4E0B;&#xFF1A;<br><img src="../../../img/p1.png" alt="p1"></p>
<blockquote>
<p>&#x8FD9;&#x4E9B;&#x7B26;&#x53F7;&#x4E0D;&#x80FD;&#x88AB;&#x9009;&#x53D6;    </p>
</blockquote>
<h2 id="enots">E:not(s)</h2>
<blockquote>
<p>&#x5339;&#x914D;&#x4E0D;&#x542B;&#x6709;s&#x9009;&#x62E9;&#x7B26;&#x7684;&#x5143;&#x7D20;E</p>
</blockquote>
<ol>
<li>&#x5229;&#x7528;&#x8FD9;&#x4E2A;&#x4F2A;&#x7C7B;&#x53EF;&#x4EE5;&#x5199;&#x4E00;&#x4E2A;&#x5B8C;&#x5168;&#x6CA1;&#x6709;&#x7528;&#x5904;&#x7684;&#x9009;&#x62E9;&#x5668;&#x3002; &#x4F8B;&#x5982;&#xFF0C; :not(*) &#x5339;&#x914D;&#x4EFB;&#x4F55;&#x975E;&#x5143;&#x7D20;&#x7684;&#x5143;&#x7D20;&#xFF0C;&#x56E0;&#x6B64;&#x8FD9;&#x4E2A;&#x89C4;&#x5219;&#x5C06;&#x6C38;&#x8FDC;&#x4E0D;&#x4F1A;&#x88AB;&#x5E94;&#x7528;&#x3002;</li>
<li>&#x5229;&#x7528;&#x8FD9;&#x4E2A;&#x4F2A;&#x7C7B;&#x53EF;&#x4EE5;&#x91CD;&#x5199;&#x5176;&#x5B83;&#x89C4;&#x5219;&#x3002; &#x4F8B;&#x5982;&#xFF0C; foo:not(bar) &#x548C;foo&#x5C06;&#x5339;&#x914D;&#x540C;&#x6837;&#x7684;&#x5143;&#x7D20;&#x3002; &#x4F46;&#x662F;&#x524D;&#x8005;&#x7684;&#x4F18;&#x5148;&#x7EA7;&#x66F4;&#x9AD8;&#x3002;</li>
<li>:not(foo){} &#x5C06;&#x5339;&#x914D;&#x4EFB;&#x4F55;&#x975E;foo&#x5143;&#x7D20;&#xFF0C;&#x5305;&#x62EC;html&#x548C;body&#x3002;</li>
<li>&#x8FD9;&#x4E2A;&#x9009;&#x62E9;&#x5668;&#x53EA;&#x4F1A;&#x5E94;&#x7528;&#x5728;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x4E0A;&#xFF0C; &#x4F60;&#x4E0D;&#x80FD;&#x7528;&#x5B83;&#x5728;&#x6392;&#x9664;&#x6240;&#x6709;&#x7956;&#x5148;&#x5143;&#x7D20;&#x3002; &#x4E3E;&#x4F8B;&#x6765;&#x8BF4;&#xFF0C; body :not(table) a &#x5C06;&#x4F9D;&#x65E7;&#x4F1A;&#x5E94;&#x7528;&#x5728;table&#x5185;&#x90E8;&#x7684;<code>&lt;a&gt;</code>&#x4E0A;, &#x56E0;&#x4E3A;<code>&lt;tr&gt;</code>&#x5C06;&#x4F1A;&#x88AB;:not() &#x8FD9;&#x90E8;&#x5206;&#x9009;&#x62E9;&#x5668;&#x5339;&#x914D;&#x3002;</li>
</ol>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">p</span>:<span class="hljs-value"><span class="hljs-function">not</span>(.classy) { color: red</span></span>; }
<span class="hljs-rule"><span class="hljs-attribute">body </span>:<span class="hljs-value"><span class="hljs-function">not</span>(p) { color: green</span></span>; }
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">p</span>&gt;</span>Some text.<span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">p</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;classy&quot;</span>&gt;</span>Some other text.<span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">span</span>&gt;</span>One more text<span class="hljs-tag">&lt;<span class="hljs-title">span</span>&gt;</span>
</code></pre>
<h2 id="root">root</h2>
<blockquote>
<p>&#x5339;&#x914D;E&#x5143;&#x7D20;&#x5728;&#x6587;&#x6863;&#x7684;&#x6839;&#x5143;&#x7D20;&#x3002;&#x5E38;&#x6307;html&#x5143;&#x7D20;</p>
</blockquote>
<p>:root &#x8FD9;&#x4E2A; CSS &#x4F2A;&#x7C7B;&#x5339;&#x914D;&#x6587;&#x6863;&#x6811;&#x7684;&#x6839;&#x5143;&#x7D20;&#x3002;&#x5BF9;&#x4E8E; HTML &#x6765;&#x8BF4;&#xFF0C;:root &#x8868;&#x793A; <html> &#x5143;&#x7D20;&#xFF0C;&#x9664;&#x4E86;&#x4F18;&#x5148;&#x7EA7;&#x66F4;&#x9AD8;&#x4E4B;&#x5916;&#xFF0C;&#x4E0E; html &#x9009;&#x62E9;&#x5668;&#x76F8;&#x540C;&#x3002;</html></p>
<p><strong>&#x5728;&#x58F0;&#x660E;&#x5168;&#x5C40; CSS &#x53D8;&#x91CF;&#x65F6; :root &#x4F1A;&#x5F88;&#x6709;&#x7528;&#xFF1A;</strong></p>
<pre><code class="lang-css"><span class="hljs-pseudo">:root</span><span class="hljs-rules">{
    <span class="hljs-rule"><span class="hljs-attribute">font-size</span>:<span class="hljs-value"> <span class="hljs-number">50px</span></span></span>;
}</span>
</code></pre>
<h2 id="firstchild&#xFF08;lastchild&#x7528;&#x6CD5;&#x7C7B;&#x4F3C;&#xFF09;">first-child&#xFF08;last-child&#x7528;&#x6CD5;&#x7C7B;&#x4F3C;&#xFF09;</h2>
<blockquote>
<p>:first-child CSS&#x4F2A;&#x7C7B; &#x4EE3;&#x8868;&#x4E86;&#x4E00;&#x7EC4;&#x5144;&#x5F1F;&#x5143;&#x7D20;&#x4E2D;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x3002;&#x5728;level3&#x5B9E;&#x73B0;&#x4E2D;&#xFF0C;&#x88AB;&#x5339;&#x914D;&#x7684;&#x5143;&#x7D20;&#x9700;&#x8981;&#x5177;&#x6709;&#x4E00;&#x4E2A;&#x7236;&#x7EA7;&#x5143;&#x7D20;&#xFF0C;&#x800C;&#x5728;level4&#x5B9E;&#x73B0;&#x4E2D;&#x5219;&#x4E0D;&#x9700;&#x8981;&#x3002;</p>
</blockquote>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">span</span>:<span class="hljs-value">first-child {
    background-color: lime</span></span>;
}
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">span</span>&gt;</span>This span is limed!<span class="hljs-tag">&lt;/<span class="hljs-title">span</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">span</span>&gt;</span>This span is not. :(<span class="hljs-tag">&lt;/<span class="hljs-title">span</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
</code></pre>
<h2 id="onlychild">only-child</h2>
<blockquote>
<p>only-child&#x4EE3;&#x8868;&#x4E86;&#x5C5E;&#x4E8E;&#x67D0;&#x4E2A;&#x7236;&#x5143;&#x7D20;&#x7684;&#x552F;&#x4E00;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;</p>
</blockquote>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">span</span>:<span class="hljs-value">only-child {
  color: red</span></span>;
}
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">span</span>&gt;</span>This span is the only child of its father<span class="hljs-tag">&lt;/<span class="hljs-title">span</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">span</span>&gt;</span>This span is one of the two children of its father<span class="hljs-tag">&lt;/<span class="hljs-title">span</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">span</span>&gt;</span>This span is one of the two children of its father<span class="hljs-tag">&lt;/<span class="hljs-title">span</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
</code></pre>
<blockquote>
<p>&#x7EA2;&#x8272;&#x7684;&#x53EA;&#x6709;&#x7B2C;&#x4E00;&#x53E5;&#xFF0C;&#x5C5E;&#x4E8E;div&#x7684;&#x552F;&#x4E00;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;span&#x53EA;&#x6709;&#x7B2C;&#x4E00;&#x53E5;&#x3002;</p>
</blockquote>
<h2 id="nthchildn">nth-child(n)</h2>
<blockquote>
<p>&#x5339;&#x914D;&#x7236;&#x5143;&#x7D20;&#x7684;&#x7B2C;n&#x4E2A;&#x5B50;&#x5143;&#x7D20;</p>
<ol>
<li>ul&#x4E0B;&#x9762;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;li&#x5B50;&#x5143;&#x7D20;<pre><code class="lang-css"><span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">li</span>:<span class="hljs-value"><span class="hljs-function">nth-child</span>(<span class="hljs-number">1</span>){
 background-color: pink</span></span>;
}
</code></pre>
</li>
<li>&#x63A7;&#x5236;ul&#x4E0B;&#x9762;&#x7684;&#x5947;&#x6570;&#x4F4D;&#x7F6E;&#x7684;li<pre><code class="lang-css"><span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">li</span>:<span class="hljs-value"><span class="hljs-function">nth-child</span>(odd){
 background-color: pink</span></span>;
}
</code></pre>
&#x6216;&#x8005;<pre><code class="lang-css"><span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">li</span>:<span class="hljs-value"><span class="hljs-function">nth-child</span>(<span class="hljs-number">2</span>n+<span class="hljs-number">1</span>){
 background-color: pink</span></span>;
}
</code></pre>
</li>
<li>&#x63A7;&#x5236;ul&#x4E0B;&#x9762;&#x7684;&#x5076;&#x6570;&#x4F4D;&#x7F6E;&#x7684;li<pre><code class="lang-css"><span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">li</span>:<span class="hljs-value"><span class="hljs-function">nth-child</span>(even){
 background-color: pink</span></span>;
}
</code></pre>
&#x6216;&#x8005;<pre><code class="lang-css"><span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">li</span>:<span class="hljs-value"><span class="hljs-function">nth-child</span>(<span class="hljs-number">2</span>n){
 background-color: pink</span></span>;
}
</code></pre>
</li>
</ol>
</blockquote>
<h2 id="nthlastchildn">nth-last-child(n)</h2>
<blockquote>
<p>&#x5339;&#x914D;&#x7236;&#x5143;&#x7D20;&#x7684;&#x5012;&#x6570;&#x7B2C;n&#x4E2A;&#x5B50;&#x5143;&#x7D20;E&#x3002;</p>
</blockquote>
<p>&#x5B83;&#x57FA;&#x672C;&#x4E0A;&#x548C; :nth-child &#x4E00;&#x6837;&#xFF0C;&#x53EA;&#x662F;&#x5B83;&#x4ECE;&#x7ED3;&#x5C3E;&#x5904;&#x53CD;&#x5E8F;&#x8BA1;&#x6570;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x4ECE;&#x5F00;&#x5934;&#x5904;&#x3002;</p>
<p>&#x5339;&#x914D;HTML&#x8868;&#x683C;&#x4E2D;&#x7684;&#x6700;&#x540E;&#x56DB;&#x884C;&#xFF1A;</p>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">tr</span>:<span class="hljs-value"><span class="hljs-function">nth-last-child</span>(-n+<span class="hljs-number">4</span>){
    background-color: lime</span></span>;
}
</code></pre>
<h2 id="firstoftype&#xFF08;lastoftype&#x7528;&#x6CD5;&#x7C7B;&#x4F3C;&#xFF09;">first-of-type&#xFF08;last-of-type&#x7528;&#x6CD5;&#x7C7B;&#x4F3C;&#xFF09;</h2>
<blockquote>
<p>&#x5339;&#x914D;&#x540C;&#x7C7B;&#x578B;&#x4E2D;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x540C;&#x7EA7;&#x5144;&#x5F1F;&#x5143;&#x7D20;</p>
</blockquote>
<p>&#x63A7;&#x5236;ul&#x4E0B;&#x9762;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;li&#x7C7B;&#x578B;&#x7684;&#x5B50;&#x5143;&#x7D20;,&#x540C;&#x7406;&#xFF0C;&#x6700;&#x540E;&#x662F;last-of-type</p>
<pre><code class="lang-css"><span class="hljs-tag">ul</span>&gt;<span class="hljs-rule"><span class="hljs-attribute">li</span>:<span class="hljs-value">first-of-type{
    background: black</span></span>;
}
</code></pre>
<p><strong>first-child &#x4E0E;first-of-type&#x7684;&#x533A;&#x522B;:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">div</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;test&quot;</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- &lt;a href=&quot;#&quot;&gt;&#x6D4B;&#x8BD5;&lt;/a&gt; --&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">p</span>&gt;</span>p&#x6807;&#x7B7E;<span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">&quot;#&quot;</span>&gt;</span>a&#x6807;&#x7B7E;<span class="hljs-tag">&lt;/<span class="hljs-title">a</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">&quot;#&quot;</span>&gt;</span>a&#x6807;&#x7B7E;<span class="hljs-tag">&lt;/<span class="hljs-title">a</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
</code></pre>
<pre><code class="lang-css">//CSS&#x90E8;&#x5206;
/* a:first-child&#x662F;.test&#x4E0B;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x7ED3;&#x6784;&#x6807;&#x7B7E;&#xFF0C;&#x800C;&#x4E14;&#x662F;a&#x6807;&#x7B7E;&#xFF0C;&#x4E0D;&#x662F;&#x5219;&#x4E0D;&#x8D77;&#x6548;&#x679C; */
  .test a:first-child{color:red;}
/* a:first-of-type&#x4E0D;&#x9700;&#x8981;&#x662F;&#x7B2C;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;&#x53EA;&#x9700;&#x8981;.test&#x4E0B;&#x7684;a&#x6807;&#x7B7E;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5373;&#x53EF; */
  .test a:first-of-type{font-size:55px;}
</code></pre>
<h2 id="onlyoftype">only-of-type</h2>
<blockquote>
<p>only-of-type &#x4EE3;&#x8868;&#x4E86;&#x8FD9;&#x4E2A;&#x5143;&#x7D20;&#x6CA1;&#x6709;&#x5176;&#x4ED6;&#x76F8;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x5144;&#x5F1F;&#x5143;&#x7D20;&#x3002;</p>
</blockquote>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">span</span>:<span class="hljs-value">only-of-type {
  color: red</span></span>;
}
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">span</span>&gt;</span>&#x65E0;&#x8272;<span class="hljs-tag">&lt;/<span class="hljs-title">span</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">span</span>&gt;</span>&#x65E0;&#x8272;<span class="hljs-tag">&lt;/<span class="hljs-title">span</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">span</span>&gt;</span>&#x8FD9;&#x91CC;&#x662F;&#x7EA2;&#x8272;&#x54E6;<span class="hljs-tag">&lt;/<span class="hljs-title">span</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">em</span>&gt;</span>&#x65E0;&#x8272;<span class="hljs-tag">&lt;/<span class="hljs-title">em</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
</code></pre>
<h2 id="nthoftypen&#xFF08;nthlastoftypen&#x7528;&#x6CD5;&#x7C7B;&#x4F3C;&#xFF09;">nth-of-type(n)&#xFF08;nth-last-of-type(n)&#x7528;&#x6CD5;&#x7C7B;&#x4F3C;&#xFF09;</h2>
<blockquote>
<p>&#x5339;&#x914D;&#x540C;&#x7C7B;&#x578B;&#x4E2D;&#x7684;&#x7B2C;n&#x4E2A;&#x540C;&#x7EA7;&#x5144;&#x5F1F;&#x5143;&#x7D20;</p>
</blockquote>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">p</span>:<span class="hljs-value"><span class="hljs-function">nth-of-type</span>(<span class="hljs-number">2</span>n+<span class="hljs-number">1</span>) { color: red</span></span>;}
<span class="hljs-rule"><span class="hljs-attribute">p</span>:<span class="hljs-value"><span class="hljs-function">nth-of-type</span>(<span class="hljs-number">2</span>n) { color: blue</span></span>;}
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>&#x65E0;&#x8272;<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">p</span>&gt;</span>&#x7EA2;&#x8272;<span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">p</span>&gt;</span>&#x84DD;&#x8272;<span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>&#x65E0;&#x8272;<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">p</span>&gt;</span>&#x7EA2;&#x8272;<span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
</code></pre>
<h2 id="empty">empty</h2>
<blockquote>
<p>&#x4EE3;&#x8868;&#x6CA1;&#x6709;&#x5B50;&#x5143;&#x7D20;&#x7684;&#x5143;&#x7D20;&#x3002; &#x8FD9;&#x91CC;&#x8BF4;&#x7684;&#x5B50;&#x5143;&#x7D20;&#xFF0C;&#x53EA;&#x8BA1;&#x7B97;&#x5143;&#x7D20;&#x7ED3;&#x70B9;&#x53CA;&#x6587;&#x672C;&#xFF08;&#x5305;&#x62EC;&#x7A7A;&#x683C;&#xFF09;&#xFF0C;&#x6CE8;&#x91CA;&#x3001;&#x8FD0;&#x884C;&#x6307;&#x4EE4;&#x4E0D;&#x8003;&#x8651;&#x5728;&#x5185;&#x3002;</p>
</blockquote>
<pre><code class="lang-css"><span class="hljs-class">.box</span> <span class="hljs-rules">{
  <span class="hljs-rule"><span class="hljs-attribute">background</span>:<span class="hljs-value"> red</span></span>;
  <span class="hljs-rule"><span class="hljs-attribute">height</span>:<span class="hljs-value"> <span class="hljs-number">200px</span></span></span>;
  <span class="hljs-rule"><span class="hljs-attribute">width</span>:<span class="hljs-value"> <span class="hljs-number">200px</span></span></span>;
}</span>
<span class="hljs-rule"><span class="hljs-attribute">.box</span>:<span class="hljs-value">empty {
  background: lime</span></span>;
}
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">div</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;box&quot;</span>&gt;</span><span class="hljs-comment">&lt;!-- I will be lime --&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">div</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;box&quot;</span>&gt;</span>I will be red<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">div</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;box&quot;</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- I will be red because of the whitespace around this comment --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
</code></pre>
<h2 id="checked">checked</h2>
<blockquote>
<p>&#x5339;&#x914D;&#x7528;&#x6237;&#x754C;&#x9762;&#x4E0A;&#x5904;&#x4E8E;&#x9009;&#x4E2D;&#x72B6;&#x6001;&#x7684;&#x5143;&#x7D20;E&#x3002;<br>(&#x7528;&#x4E8E;input type&#x4E3A;radio&#x4E0E;checkbox&#x65F6;)</p>
</blockquote>
<ul>
<li><p>&#x5904;&#x4E8E;&#x88AB;&#x9009;&#x4E2D;&#x72B6;&#x6001;&#x7684;&#x5143;&#x7D20;</p>
<pre><code class="lang-css"><span class="hljs-pseudo">:checked</span> <span class="hljs-rules">{
  <span class="hljs-rule"><span class="hljs-attribute">width</span>:<span class="hljs-value"> <span class="hljs-number">50px</span></span></span>;
  <span class="hljs-rule"><span class="hljs-attribute">height</span>:<span class="hljs-value"> <span class="hljs-number">50px</span></span></span>;
}</span>
</code></pre>
</li>
<li><p>checkbox&#x88AB;&#x9009;&#x4E2D;&#x65F6;</p>
<pre><code class="lang-css"><span class="hljs-tag">input</span><span class="hljs-attr_selector">[type=&quot;checkbox&quot;]</span><span class="hljs-pseudo">:checked</span> <span class="hljs-rules">{
  <span class="hljs-rule"><span class="hljs-attribute">display</span>:<span class="hljs-value"> none</span></span>;  
}</span>
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">input</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;checkbox&quot;</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">&quot;111&quot;</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">&quot;111&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">label</span> <span class="hljs-attribute">for</span>=<span class="hljs-value">&quot;111&quot;</span>&gt;</span>111<span class="hljs-tag">&lt;/<span class="hljs-title">label</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">input</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;checkbox&quot;</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">&quot;111&quot;</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">&quot;222&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">label</span> <span class="hljs-attribute">for</span>=<span class="hljs-value">&quot;222&quot;</span>&gt;</span>222<span class="hljs-tag">&lt;/<span class="hljs-title">label</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">input</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;checkbox&quot;</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">&quot;111&quot;</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">&quot;333&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">label</span> <span class="hljs-attribute">for</span>=<span class="hljs-value">&quot;333&quot;</span>&gt;</span>333<span class="hljs-tag">&lt;/<span class="hljs-title">label</span>&gt;</span>
</code></pre>
</li>
<li><p>radio&#x88AB;&#x9009;&#x4E2D;&#x65F6;</p>
<pre><code class="lang-css"><span class="hljs-tag">input</span><span class="hljs-attr_selector">[type=&quot;radio&quot;]</span><span class="hljs-pseudo">:checked</span> <span class="hljs-rules">{
  <span class="hljs-rule"><span class="hljs-attribute">margin-left</span>:<span class="hljs-value"> <span class="hljs-number">25px</span></span></span>;
}</span>
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">input</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;radio&quot;</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">&quot;sex&quot;</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">&quot;male&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">label</span> <span class="hljs-attribute">for</span>=<span class="hljs-value">&quot;male&quot;</span>&gt;</span>male<span class="hljs-tag">&lt;/<span class="hljs-title">label</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">input</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;radio&quot;</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">&quot;sex&quot;</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">&quot;female&quot;</span>/&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">label</span> <span class="hljs-attribute">for</span>=<span class="hljs-value">&quot;female&quot;</span>&gt;</span>female<span class="hljs-tag">&lt;/<span class="hljs-title">label</span>&gt;</span>
</code></pre>
</li>
<li><p>option&#x88AB;&#x9009;&#x4E2D;&#x65F6;</p>
<pre><code class="lang-css"><span class="hljs-rule"><span class="hljs-attribute">option</span>:<span class="hljs-value">checked {
  color: red</span></span>;
}
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">select</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">&quot;123&quot;</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">option</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">&quot;111&quot;</span>&gt;</span>111<span class="hljs-tag">&lt;/<span class="hljs-title">option</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">option</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">&quot;222&quot;</span>&gt;</span>222<span class="hljs-tag">&lt;/<span class="hljs-title">option</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">option</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">&quot;333&quot;</span>&gt;</span>333<span class="hljs-tag">&lt;/<span class="hljs-title">option</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">select</span>&gt;</span>
</code></pre>
</li>
</ul>
<h2 id="enabled">enabled</h2>
<blockquote>
<p>&#x8868;&#x793A;&#x4EFB;&#x4F55;&#x542F;&#x7528;&#x7684;&#xFF08;enabled&#xFF09;&#x5143;&#x7D20;&#x3002;   </p>
</blockquote>
<p>&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x80FD;&#x591F;&#x88AB;&#x6FC0;&#x6D3B;&#xFF08;&#x5982;&#x9009;&#x62E9;&#x3001;&#x70B9;&#x51FB;&#x6216;&#x63A5;&#x53D7;&#x6587;&#x672C;&#x8F93;&#x5165;&#xFF09;&#x6216;&#x83B7;&#x53D6;&#x7126;&#x70B9;&#xFF0C;&#x5219;&#x8BE5;&#x5143;&#x7D20;&#x662F;&#x542F;&#x7528;&#x7684;&#x3002;   </p>
<p>&#x4E0B;&#x9762;&#x4EE3;&#x7801;&#x5339;&#x914D;&#x80FD;&#x88AB;&#x6FC0;&#x6D3B;&#x7684;&#x6587;&#x672C;&#x8F93;&#x5165;&#x6846;</p>
<pre><code class="lang-css"><span class="hljs-tag">input</span><span class="hljs-attr_selector">[type=&quot;text&quot;]</span><span class="hljs-pseudo">:enabled</span><span class="hljs-rules">{
    <span class="hljs-rule"><span class="hljs-attribute">border</span>:<span class="hljs-value"> <span class="hljs-number">1px</span> solid <span class="hljs-hexcolor">#090</span></span></span>;
}</span>
</code></pre>
<h2 id="disabled">disabled</h2>
<blockquote>
<p>&#x8868;&#x793A;&#x4EFB;&#x4F55;&#x88AB;&#x7981;&#x7528;&#x7684;&#x5143;&#x7D20;&#x3002;</p>
</blockquote>
<p>&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x4E0D;&#x80FD;&#x88AB;&#x6FC0;&#x6D3B;&#xFF08;&#x5982;&#x9009;&#x62E9;&#x3001;&#x70B9;&#x51FB;&#x6216;&#x63A5;&#x53D7;&#x6587;&#x672C;&#x8F93;&#x5165;&#xFF09;&#x6216;&#x83B7;&#x53D6;&#x7126;&#x70B9;&#xFF0C;&#x5219;&#x8BE5;&#x5143;&#x7D20;&#x5904;&#x4E8E;&#x88AB;&#x7981;&#x7528;&#x72B6;&#x6001;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x4EE3;&#x7801;&#x5339;&#x914D;&#x4E0D;&#x80FD;&#x88AB;&#x6FC0;&#x6D3B;&#x7684;&#x6587;&#x672C;&#x8F93;&#x5165;&#x6846;</p>
<pre><code class="lang-css"><span class="hljs-tag">input</span><span class="hljs-attr_selector">[type=&quot;text&quot;]</span><span class="hljs-pseudo">:disabled</span><span class="hljs-rules">{
    <span class="hljs-rule"><span class="hljs-attribute">border</span>:<span class="hljs-value"> <span class="hljs-number">1px</span> solid <span class="hljs-hexcolor">#ccc</span></span></span>;
}</span>
</code></pre>
<h2 id="target">target</h2>
<blockquote>
<p>&#x4EE3;&#x8868;&#x4E00;&#x4E2A;&#x7279;&#x6B8A;&#x7684;&#x5143;&#x7D20;&#xFF0C;&#x5B83;&#x7684;id&#x662F;URI&#x7684;&#x7247;&#x6BB5;&#x6807;&#x8BC6;&#x7B26;</p>
</blockquote>
<ol>
<li><p>target&#x80FD;&#x5F88;&#x597D;&#x7684;&#x5E94;&#x7528;&#x4E8E;&#x672A;&#x663E;&#x793A;&#x7684;&#x5143;&#x7D20;&#xFF1A;</p>
<pre><code class="lang-css"><span class="hljs-id">#newcomment</span> <span class="hljs-rules">{
<span class="hljs-rule"><span class="hljs-attribute">display</span>:<span class="hljs-value"> none</span></span>;
}</span>
<span class="hljs-id">#newcomment</span><span class="hljs-pseudo">:target</span> <span class="hljs-rules">{
<span class="hljs-rule"><span class="hljs-attribute">display</span>:<span class="hljs-value"> block</span></span>;
}</span>
</code></pre>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">p</span>&gt;</span>
 <span class="hljs-tag">&lt;<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">&quot;#newcomment&quot;</span>&gt;</span>Add a comment<span class="hljs-tag">&lt;/<span class="hljs-title">a</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">div</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">&quot;newcomment&quot;</span>&gt;</span>
 <span class="hljs-tag">&lt;<span class="hljs-title">form</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">&quot;myForm&quot;</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-title">p</span>&gt;</span>Write your comment:<span class="hljs-tag">&lt;<span class="hljs-title">br</span> /&gt;</span>
         <span class="hljs-tag">&lt;<span class="hljs-title">input</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">&quot;text&quot;</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">&quot;myText&quot;</span>/&gt;</span>
     <span class="hljs-tag">&lt;/<span class="hljs-title">p</span>&gt;</span>
 <span class="hljs-tag">&lt;/<span class="hljs-title">form</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
</code></pre>
</li>
<li></li>
</ol>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../../md/CSS/selector/shuxing.html" class="navigation navigation-prev " aria-label="Previous page: 属性选择器"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../../md/CSS/selector/weiduixiang.html" class="navigation navigation-next " aria-label="Next page: 伪对象选择器"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../../gitbook/app.js"></script>

    
    <script src="../../../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="../../../gitbook/plugins/gitbook-plugin-splitter/splitter.js"></script>
    

    
    <script src="../../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"toggle-chapters":{},"splitter":{},"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
    </body>
    <!-- End of book  -->
</html>
